<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <link rel="Shortcut Icon" href="../images/aecc.ico" type="image/x-icon" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="../StaticFiles/element-ui/element-ui.css">
  <link rel="stylesheet" href="../StaticFiles/nprogress/nprogress.min.css">
  <link rel="stylesheet" href="../styles/vue-page-common.css">
  <script src="../Scripts/vue.min.js"></script>
  <script src="../StaticFiles/element-ui/element-ui.js"></script>
  <script src="../Scripts/axios.min.js"></script>
  <script src="../StaticFiles/nprogress/nprogress.min.js"></script>
  <script src="../Scripts/dayjs.min.js"></script>
  <script src="../Scripts/axios.config.js"></script>
  <title>MES用户操作记录查询报表</title>
</head>

<body>
  <div id="app" v-cloak v-on:keyup.enter="getData">
    <!-- 报表标题 -->
    <vue2-report-header :title="'MES用户操作记录查询报表'"></vue2-report-header>
    <div style="padding: 10px;">
      <!-- 查询条件区 -->
      <el-form :inline="true" :model="queryInfo" ref="queryInfoRef" :label-position="'left'">
        <el-form-item label="被添加或删除的【员工号】:">
          <el-autocomplete v-model.trim="queryInfo.employeename" placeholder="请输入" :trigger-on-focus="false"
            :fetch-suggestions="searchEmployeenameAsync" :value-key="'employeename'" :debounce="500">
          </el-autocomplete>
        </el-form-item>

        <el-form-item label="被添加或删除的【员工姓名】:">
          <el-autocomplete v-model.trim="queryInfo.fullname" placeholder="请输入" :trigger-on-focus="false"
            :fetch-suggestions="searchFullnameAsync" :value-key="'fullname'" :debounce="500">
          </el-autocomplete>
        </el-form-item>

        <el-form-item label="被添加或删除的【员工id】:">
          <el-autocomplete v-model.trim="queryInfo.employeeid" placeholder="请输入" :trigger-on-focus="false"
            :fetch-suggestions="searchEmployeeidAsync" :value-key="'employeeid'" :debounce="500">
          </el-autocomplete>
        </el-form-item>

        <el-form-item label="操作者【员工号】:">
          <el-autocomplete v-model.trim="queryInfo.oper_user_no" placeholder="请输入" :trigger-on-focus="false"
            :fetch-suggestions="searchEmployeenameAsync" :value-key="'employeename'" :debounce="500">
          </el-autocomplete>
        </el-form-item>

        <el-form-item label="操作者【员工姓名】:">
          <el-autocomplete v-model.trim="queryInfo.oper_user_name" placeholder="请输入" :trigger-on-focus="false"
            :fetch-suggestions="searchFullnameAsync" :value-key="'fullname'" :debounce="500">
          </el-autocomplete>
        </el-form-item>

        <el-form-item label="操作类型:">
          <el-select v-model="queryInfo.executeaction" placeholder="请选择" clearable filterable style="width: 120px;">
            <el-option :key="'添加'" :label="'添加'" :value="'添加'"></el-option>
            <el-option :key="'Delete'" :label="'删除'" :value="'Delete'"></el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="操作时间:">
          <el-date-picker v-model="queryInfo.oper_date" type="daterange" range-separator="至" value-format="yyyy-MM-dd"
            start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions"></el-date-picker>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="small" @click="getData">查询</el-button>
        </el-form-item>
      </el-form>

      <!-- 表格显示区 -->
      <el-table v-loading="loading" v-loading.fullscreen.lock="loading" :element-loading-text="loadingText"
        element-loading-background="rgba(0,0,0,0.8)" :data="dataList" stripe border>
        <el-table-column type="index" width="50px"></el-table-column>
        <el-table-column label="操作者【员工号】" prop="oper_user_no" width="140" show-overflow-tooltip></el-table-column>
        <el-table-column label="操作者【员工姓名】" prop="oper_user_name" width="140" show-overflow-tooltip></el-table-column>
        <el-table-column label="操作时间" prop="oper_date" width="180">
          <template slot-scope="scope" v-if="scope.row.oper_date">
            {{scope.row.oper_date.replace('T',' ')}}
          </template>
        </el-table-column>
        <el-table-column label="操作类型" prop="executeaction" width="100">
          <template slot-scope="scope">
            <el-tag :type="scope.row.executeaction === '删除' ? 'danger' : 'success'">{{scope.row.executeaction}}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column label="被添加或删除的【员工号】" prop="employeename" width="200" show-overflow-tooltip></el-table-column>
        <el-table-column label="被添加或删除的【员工姓名】" prop="fullname" width="200" show-overflow-tooltip> </el-table-column>
        <el-table-column label="被添加或删除的【员工id】" prop="employeeid"></el-table-column>
      </el-table>

      <!-- 分页组件 -->
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
        :current-page="queryInfo.currentPage" :page-sizes="[12,50,100]" :page-size="queryInfo.pageSize"
        layout="prev,pager,next,jumper,sizes,total" :total="total">
      </el-pagination>

      <!-- 回到顶部 -->
      <el-backtop></el-backtop>
    </div>
  </div>
  <script type="module">
    import { fetchSuggestion, exportExcelData } from '../Scripts/hooks/useCommonMethod.js'
    import { prevWeek, thisWeek, nextWeek, prevMonth, thisMonth, nextMonth } from '../Scripts/hooks/useDateShortCut.js'
    import Vue2ReportHeader from '../Scripts/components/Vue2ReportHeader.js'
    const app = new Vue({
      el: '#app',
      components: { Vue2ReportHeader },
      data: {
        queryInfo: {
          employeeid: '',
          employeename: '',
          fullname: '',
          executeaction: '',
          oper_user_no: '',
          oper_user_name: '',
          oper_date: '',
          currentPage: 1,//当前页
          pageSize: 12//每页显示条数
        },
        total: 0,
        loading: false,
        loadingText: '数据加载中...',
        dataList: [],
        pickerOptions: { shortcuts: [prevWeek, thisWeek, nextWeek, prevMonth, thisMonth, nextMonth] }
      },
      methods: {
        // 查询用户姓名
        searchFullnameAsync(value, callback) {
          fetchSuggestion({ actionName: 'getEmployeeAsync', name: 'fullname', value, callback, triggerLength: 1 })
        },
        // 查询员工号
        searchEmployeenameAsync(value, callback) {
          fetchSuggestion({ actionName: 'getEmployeeAsync', name: 'employeename', value, callback, triggerLength: 1 })
        },
        // 查询员工id
        searchEmployeeidAsync(value, callback) {
          fetchSuggestion({ actionName: 'getEmployeeAsync', name: 'employeeid', value, callback, triggerLength: 1 })
        },
        //查询数据
        async getData() {
          this.$refs['queryInfoRef'].validate(async (valid) => {
            if (!valid) {
              return this.$message.error('必填项不能为空');
            } else {
              this.loading = true
              this.loadingText = '数据加载中...'
              const { data: { data, meta, total } } = await axios.post('../handler/report/EmployeeAuditTrial.ashx?action=getData', {
                type: 'getData',
                ...this.queryInfo
              })
              this.loading = false;
              if (meta.status === 500) { return this.$message.error(meta.msg); }
              this.dataList = data;
              this.total = total;
            }
          })
        },
        handleCurrentChange(newPage) {
          this.queryInfo.currentPage = newPage;
          this.getData();
        },
        handleSizeChange(newSize) {
          this.queryInfo.pageSize = newSize;
          this.getData();
        }
      },
      watch: {
        queryInfo: { handler() { this.queryInfo.currentPage = 1 }, deep: true }
      }
    })
  </script>
</body>

</html>